package com.example.waitnotify;

/**
 * @author:CrazyShaQiuShi
 * @email:3105334046@qq.com
 * @descript:
 * @version:1.0.0
 */
public class RunWait {

    public static class ThreadDemo1 extends Thread {
        private User user;

        public ThreadDemo1(User user) {
            this.user = user;
        }

        @Override
        public void run() {
            synchronized (user) {
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                user.notify();
            }
        }
    }

    public static void main(String[] args) {
        User user = new User();
        user.setId(1);
        user.setName("admin");
        Thread thread1 = new ThreadWait(user);
        thread1.start();

        Thread thread2 = new ThreadDemo1(user);
        thread2.start();


    }
}
